<?php
function pre($msg){
    echo "<pre>";
    print_r($msg);
    exit;
}
//二维数组去重
function arrayAssocUnique($arr, $key) {
    $tmpArr = [];
    foreach ($arr as $unk => $unv){
        if (!is_array($unv)){
            continue;
        }
        $tmpArr[$unv[$key]] = $unv;
        unset($arr[$unk]);
    }
    $arr = array_merge($arr,$tmpArr);
 
    return $arr;
}

/**
 * 去重并且获得重复值
 * @param array $arr
 * @param string $key
 * @return array[]|array[][]
 */
function arrayUniqueHasOne($arr, $key) {
    $repeatArr = [];
    $tmpArr = [];
    foreach ($arr as $unk => $unv){
        if (!is_array($unv)){
            continue;
        }
        $keyArr = array_keys($tmpArr);
        if (in_array($unv[$key], $keyArr)){
            $repeatArr[] = $unv;
        }else {
            $tmpArr[$unv[$key]] = $unv;
            unset($arr[$unk]);
        }
    }
    //$arr = array_merge($arr,$tmpArr);
   // pre($tmpArr);
    return ['arr' => $tmpArr, 'repeat' => $repeatArr];
}